/**
 * ReportingService.java creation date 2011-7-18 上午09:44:43 
 * @author dj
 * Email:dj.dai@accentrix.com
 * 
 * Copyright (c) 2001-2008 Accentrix Company Limited. All Rights Reserved.
 * 
 * Accentrix Company Limited. ("Accentrix") retains copyright on all text, source
 * and binary code contained in this software and documentation. Accentrix grants
 * Licensee a limited license to use this software, provided that this copyright
 * notice and license appear on all copies of the software. The software source
 * code is provided for reference purposes only and may not be copied, modified 
 * or distributed.
 * 
 * THIS SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS," WITHOUT ANY WARRANTY OF
 * ANY KIND UNLESS A SEPARATE WARRANTIES IS PURCHASED FROM ACCENTRIX AND REMAINS
 * VALID.  ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. ACCENTRIX SHALL NOT BE LIABLE
 * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING OR MODIFYING THE
 * SOFTWARE OR ITS DERIVATIVES.
 * 
 * IN NO EVENT WILL ACCENTRIX BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
 * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES,
 * HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE
 * USE OF OR INABILITY TO USE SOFTWARE, EVEN IF ACCENTRIX HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 * 
 */

package com.lightsaber.trade.as.service.reporting;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lightsaber.trade.as.dao.param.CampusDao;
import com.lightsaber.trade.as.dao.param.DeptDao;
import com.lightsaber.trade.as.entity.param.Campus;
import com.lightsaber.trade.as.entity.param.Dept;
import com.lightsaber.trade.as.service.category.CategoryService;
import com.lightsaber.trade.as.service.param.ParamObject;
import com.lightsaber.trade.as.service.param.impl.ParamObjectImpl;

@Service
@Transactional
public class ReportingParamService {
    @Autowired
    private CategoryService categoryService;

    @Autowired
    CampusDao campusDao;

    @Autowired
    DeptDao deptDao;

    public List<ParamObject> getCampusList() {
        List<ParamObject> campusList = new ArrayList<ParamObject>();

        List<Campus> campuses = campusDao.getAll();

        for (Campus c : campuses) {
            ParamObject o = new ParamObjectImpl(c.getCampus(), c.getCampusDisplayCode());
            campusList.add(o);
        }

        return campusList;
    }

    public List<ParamObject> getDeptListByCampus(final String campuses[]) {
        List<ParamObject> deptList = new ArrayList<ParamObject>();

        List<Dept> depts = deptDao.getDeptListByCampuses(campuses);

        for (Dept d : depts) {
            ParamObject o = new ParamObjectImpl(d.getDept(), d.getShortDesc());
            deptList.add(o);
        }

        return deptList;
    }

    public List<ParamObject> getOfferingUnitList(final String campusId) {
        List<ParamObject> offeringUnitList = new ArrayList<ParamObject>();
        for (int i = 1; i <= 5; i++) {
            ParamObject o = new ParamObjectImpl("ofunitcode " + i, "offeringUnit Name " + i);
            offeringUnitList.add(o);
        }
        return offeringUnitList;
    }

    public List<ParamObject> getOperatingUnitList(final String selectedCampusId) {
        List<ParamObject> operatingUnitList = new ArrayList<ParamObject>();
        for (int i = 1; i <= 5; i++) {
            ParamObject o = new ParamObjectImpl("operatingUnitCode " + i, "operatingUnit Name " + i);
            operatingUnitList.add(o);
        }
        return operatingUnitList;
    }

    public List<ParamObject> getPlanningExerciseList() {
        List<ParamObject> planningExerciseList = new ArrayList<ParamObject>();
        Map<Integer, String> planingExercieseList = categoryService.getAllCategoryOrderByYear();

        for (Map.Entry<Integer, String> m : planingExercieseList.entrySet()) {
            planningExerciseList.add(new ParamObjectImpl(m.getKey().toString(), m.getValue()));
        }
        return planningExerciseList;
    }

    public List<ParamObject> getPlanNameList(final String planingExicerciseId) {
        List<ParamObject> planNameList = new ArrayList<ParamObject>();

        return planNameList;
    }

    public List<ParamObject> getArchiveImageList(final String planingExicerciseId) {
        List<ParamObject> archiveImageList = new ArrayList<ParamObject>();

        return archiveImageList;
    }

}
